<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns a key-value array of locale ID subtag elements.</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="locale.lookup.html">Locale::lookup</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="locale.setdefault.html">Locale::setDefault</a></div>
 <div class="up"><a href="class.locale.html">Locale</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="locale.parselocale" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Locale::parseLocale</h1>
  <h1 class="refname">locale_parse</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Locale::parseLocale</span> -- <span class="refname">locale_parse</span> &mdash; <span class="dc-title">Returns a key-value array of locale ID subtag elements.</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-locale.parselocale-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">array</span> 
   <span class="methodname"><strong>Locale::parseLocale</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>
   )</div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> 
   <span class="methodname"><strong>locale_parse</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>
   )</div>

  <p class="para rdfs-comment">
   Returns a key-value array of locale ID subtag elements.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-locale.parselocale-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">locale</code></em></dt>

     <dd>

      <p class="para">
       The locale to extract the subtag array from. Note: The &#039;variant&#039; and
       &#039;private&#039; subtags can take maximum 15 values whereas &#039;extlang&#039; can take
       maximum 3 values.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-locale.parselocale-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an array containing a list of key-value pairs, where the keys
   identify the particular locale ID subtags, and the values are the
   associated subtag values. The array will be ordered as the locale id
   subtags e.g. in the locale id if variants are &#039;-varX-varY-varZ&#039; then the
   returned array will have variant0=&gt;varX , variant1=&gt;varY ,
   variant2=&gt;varZ
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-locale.parselocale-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2498">
   <p><strong>Example #1 <span class="function"><strong>locale_parse()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$arr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">locale_parse</span><span style="color: #007700">(</span><span style="color: #DD0000">'sl-Latn-IT-nedis'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$arr</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(</span><span style="color: #0000BB">$arr&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$key</span><span style="color: #DD0000">&nbsp;:&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #DD0000">&nbsp;,&nbsp;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <div class="example" id="example-2499">
   <p><strong>Example #2 OO example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$arr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">Locale</span><span style="color: #007700">::</span><span style="color: #0000BB">parseLocale</span><span style="color: #007700">(</span><span style="color: #DD0000">'sl-Latn-IT-nedis'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$arr</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(</span><span style="color: #0000BB">$arr&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$key</span><span style="color: #DD0000">&nbsp;:&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #DD0000">&nbsp;,&nbsp;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <p class="para">以上例程会输出：</p>
  <div class="example-contents screen">
<div class="cdata"><pre>
language : sl , script : Latn , region : IT , variant0 : NEDIS ,
</pre></div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-locale.parselocale-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="locale.composelocale.html" class="function" rel="rdfs-seeAlso">locale_compose()</a> - Returns a correctly ordered and delimited locale ID</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="locale.lookup.html">Locale::lookup</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="locale.setdefault.html">Locale::setDefault</a></div>
 <div class="up"><a href="class.locale.html">Locale</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
